package com.base.caselib;

import android.text.TextUtils;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.base.caselib.bean.AskBean;
import com.base.caselib.bean.PdfType;
import com.base.caselib.databinding.ActivityAskrecordBinding;
import com.base.caselib.presenter.AskRecordPresenter;
import com.base.caselib.view.AskRecordView;
import com.base.commonlib.base.CBaseBarMvpActivity;
import com.base.commonlib.widget.SingleChooseDialog;

/**
 * 询问笔录
 * Created by weikailiang on 2019/10/29.
 */
@Route(path = "/askrecord/ask")
public class AskRecordActivity extends CBaseBarMvpActivity<AskRecordPresenter> implements AskRecordView{
    private ActivityAskrecordBinding mBinding;
    @Autowired
    String mFormId;
    @Autowired
    String mCaseId;
    @Override
    protected int getLayoutResource() {
        return R.layout.activity_askrecord;
    }

    @Override
    protected void init() {
        super.init();
        mBinding = (ActivityAskrecordBinding) mRootBinding;
        mPresenter = new AskRecordPresenter(this,this);
        setBackNavigation();
        setBarTitle("一般案件");
        setRigImg(R.drawable.ic_print, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(!mPresenter.mHasSaved)
                {
                    showMes("请先保存");
                    return;
                }

            }
        });
        mPresenter.getAskRecord(mCaseId);

    }

    @Override
    protected void start() {

        mBinding.save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (TextUtils.isEmpty(mBinding.content.getText().toString().trim())){
                    showMes("请输入笔录");
                    return;
                }
                mPresenter.saveAskRecord(mCaseId,mBinding.content.getText().toString().trim());
            }
        });
    }

    @Override
    public void getAskRecordBean(AskBean bean) {
        if (bean != null){
            if (bean.getInvestigationContent() != null && !TextUtils.isEmpty(bean.getInvestigationContent())) {
                mPresenter.mHasSaved = true;
                mBinding.content.setText(bean.getInvestigationContent());
            }
        }
    }
}
